import { Menu } from 'antd';
import { UserOutlined, LaptopOutlined, NotificationOutlined } from '@ant-design/icons';
import { Link } from 'react-router-dom';

const SideMenu = ({ activeMenuKey, onMenuItemClick }) => {
  const items = [
    {
      key: 'sub1',
      label: <span><UserOutlined />首页</span>,
      children: [],
    },
    {
      key: 'sub2',
      label: <span>商品管理</span>,
      children: [
        { key: '1', label: '商品列表' },
        { key: '2', label: '机会商品' },
        { key: '3', label: '样品管理' },
        { key: '4', label: '上新生命周期' },
        { key: '5', label: '图片更新' },
      ],
    },
    {
      key: 'sub3',
      label: <span><LaptopOutlined />备货单管理</span>,
      children: [
        { key: '6', label: '我的备货单' },
        { key: '7', label: '发货台' },
        { key: '8', label: '发货单列表' },
        { key: '9', label: '物流计费核实' },
      ],
    },
    {
      key: 'sub4',
      label: <span><LaptopOutlined />价格管理</span>,
      children: [
        { key: '10', label: '调价管理' },
      ],
    },
    {
      key: 'sub5',
      label: <span><LaptopOutlined />结算管理</span>,
      children: [
        { key: '11', label: <Link to="/fund-center">资金中心</Link> },
        { key: '12', label: <Link to="/reconciliation-center">对账中心</Link> },
        // 修复：将 Link 包裹在 span 中，确保点击区域正确
        { key: '13', label: <span><Link to="/fund-limit">资金限制</Link></span> },
        { key: '14', label: <span><Link to="/settlement-data">结算数据</Link></span> },
      ],
    },
    {
      key: 'sub6',
      label: <span><LaptopOutlined />质量管理</span>,
      children: [
        { key: '15', label: '质量看板' },
      ],
    },
    {
      key: 'sub7',
      label: <span><LaptopOutlined />授权管理</span>,
      children: [
        { key: '16', label: '授权' },
      ],
    },
    {
      key: 'sub8',
      label: <span><LaptopOutlined />店铺营销</span>,
      children: [
        { key: '17', label: '营销活动' },
      ],
    },
    {
      key: 'sub9',
      label: <span><LaptopOutlined />店铺管理</span>,
      children: [
        { key: '18', label: '店铺装修' },
      ],
    },
    {
      key: 'sub10',
      label: <span><LaptopOutlined />合成中心</span>,
      children: [
        { key: '19', label: '看板' },
      ],
    },
    {
      key: 'sub11',
      label: <span><NotificationOutlined />销售管理</span>,
      children: [
        { key: '20', label: '销售看板' },
      ],
    },
  ];

  return (
    <Menu
      mode="inline"
      selectedKeys={[activeMenuKey]}
      defaultOpenKeys={['sub5']}
      style={{ height: '100%' }}
      onClick={onMenuItemClick}
      items={items}
    />
  );
};

export default SideMenu;